// cd 项目目录
// npm i mockjs -D
// 导入mock
import Mock from  'mockjs';
// Mock.mock(url,type,数据)
// Mock.mock(url,数据) //post get put delete都会拦截
Mock.mock("http://baidu.com/user","post",function(option){
    console.log(option,"option");
    // 前端发送的请求数据可以通过option来获取，get和post略有不同
    var body = JSON.parse(option.body);
    return Mock.mock({
         "current":body.current,
        "label|10":[
            {
                "id2|+1":200,
                id:"@id",
                "noCache|1":true,
                "tabKey":"@word(7,10)",
                "title":'@ctitle(2,4)',
                "tel":/1\d{10}/,
                "address":"@county(true)",
                "pic":function(){
                    return Mock.Random.dataImage("200x100", this.title)
                },
                datetime:"@datetime()",
                des:"@cparagraph",
                email:/ \w{4,10}@(163|126|qq)\.(com|cn|net)/
            }
        ]
    })
})

// 拦截接口，生成随机数据（固定）
Mock.mock("http://baidu.com/user","get",{
    name:"mumu",
    age:18
})

// 拦截接口（现有数据）
// Mock.mock("http://baidu.com/list","get",{"code":0,"msg":"操作成功","userMsg":"","dialog":{},"data":{"userName":"","realName":"","nickname":"","levelName":"","levelIcon":"","mobile":"","mobileHide":"","avatar":"https://img2.ch999img.com/newstatic/14061/0389acf595834f27.png","level":-1,"totalPoint":0,"exceedPoint":0,"cartCount":0,"msgCount":0,"unreadCount":0,"searchPlaceholder":"兔年开新献礼，购机享最高1800元优惠！","searchHints":["兔年开新献礼，购机享最高1800元优惠！"],"freePhone":"400-008-3939","userId":0,"balance":0,"growthValue":0,"followWeChat":false,"addressSwitch":true,"wxNickName":"","qqNickName":"","birthdayDialog":{"birthday":"","textParagraph":[],"btn":{},"tip":{}},"authWxAvatarSwitch":false,"validate":false,"addCode":false,"bindWeChat":false,"conultingCustomerService":false}})s